gusucode.com > 支持向量机工具箱 - LIBSVM OSU_SVM LS_SVM源码程序 > 支持向量机工具箱 - LIBSVM OSU_SVM LS_SVM\stprtool\generalp\cliplin1.m
function [x1,y1,x2,y2,in]=cliplin1(alpha,theta,window) % [x1,y1,x2,y2,in]=cliplin1(alpha,theta,window) % % CLIPLIN1 clips the line given by the equation alpha*x=theta along % the window. It returns two points on the border of the window. % If the line is in the window then the argument is equal to 1 % else it returns 0. % % See also CLIPLIN2. % % Statistical Pattern Recognition Toolbox, Vojtech Franc, Vaclav Hlavac % (c) Czech Technical University Prague, http://cmp.felk.cvut.cz % Written Vojtech Franc (diploma thesis) 20.10.1999, 23.12.1999 % Modifications % 24. 6.00 V. Hlavac, comments polished. minx=window(1); maxx=window(2); miny=window(3); maxy=window(4); x=zeros(4,1); y=zeros(4,1); if alpha(1)==0, if alpha(2)~=0, x1=minx; y1=theta/alpha(2); x2=maxx; y2=y1; in=1; else % if alpha == 0 then it means the bad input. x1=0; y1=0; x2=0; y2=0; in=0; end elseif alpha(2)==0, x1=theta/alpha(1); y1=miny; x2=x1; y2=maxy; in=1; else y(1)=maxy; x(1)=(theta-alpha(2)*y(1))/alpha(1); y(2)=miny; x(2)=(theta-alpha(2)*y(2))/alpha(1); x(3)=maxx; y(3)=(theta-alpha(1)*x(3))/alpha(2); x(4)=minx; y(4)=(theta-alpha(1)*x(4))/alpha(2); j=0; for i=1:4, if x(i) <= maxx & x(i) >= minx & y(i) <= maxy & y(i) >= miny, if j==0, j=j+1; x1=x(i); y1=y(i); elseif j==1, j=j+1; x2=x(i); y2=y(i); end end end if j<2, x1=0; y1=0; x2=0; y2=0; in=0; else in=1; end end % elseif alpha(2)==0